import React, {useContext, useState} from 'react';
import Theme from '@/components/15- 常用Hooks/07- useContext/userContext.js';
import FunUseContextTwo from '@/components/15- 常用Hooks/07- useContext/FunUseContextTwo';

const {ThemeContext, ThemeContextTwo} = Theme;
const FunUseContextOne = () => {
    const {num, setNum} = useContext(ThemeContext);
    let [num1, setNum1] = useState(10)
    return (
        <ThemeContextTwo.Provider value={{num1, setNum1}}>
            <div>
                <h4>FunUseContextOne</h4>
                <div>num1 ==> {num1}</div>
                <button onClick={() => {
                    setNum(num + 1);
                }}>改变num ==> {num}</button>
                <FunUseContextTwo></FunUseContextTwo>
            </div>
        </ThemeContextTwo.Provider>
    );
};

export default FunUseContextOne;